IF OBJECT_ID('ssf.job_get_step_info') IS NOT NULL
	DROP FUNCTION ssf.job_get_step_info
GO

CREATE FUNCTION ssf.job_get_step_info (
	@job_id UNIQUEIDENTIFIER
)
RETURNS TABLE
AS
/*
<object_header>

<object_summary>
	<purpose><![CDATA[
Return step info from sysjobsteps for the given job_id.
	]]></purpose>
</object_summary>

</object_header>
*/

	RETURN (
		SELECT @job_id AS job_id
			, step_id
			, step_name
			, subsystem
			, command
			, database_name
			, on_success_action
			, NULLIF(on_success_step_id, 0) AS on_success_step_id
			, on_fail_action
			, NULLIF(on_fail_step_id, 0) AS on_fail_step_id
			, NULLIF(retry_attempts, 0) AS retry_attempts
			, NULLIF(retry_interval, 0) AS retry_interval
		FROM msdb.dbo.sysjobsteps WITH (NOLOCK)
		WHERE job_id = @job_id
	)
GO
